package sk.stuba.fiit.foo07.genex.logging;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger;



public aspect ExceptionLogging {
    
        Logger log = Logger.getRootLogger();
        
        ExceptionLogging() {
            PropertyConfigurator.configure("genex.properties");            
        }

        pointcut publicMethodCall():
            call(public * *(..));

        after() throwing (Exception e): publicMethodCall() {
            log.error(e);
            for(StackTraceElement se: e.getStackTrace()) {
                log.info(se.getClassName() + "." + se.getMethodName() + "() line: " + se.getLineNumber());
            }
        }
}
